<template>
  <div>
     <swiper>
     <swiper-item v-for="item in banners" :key="item.index">
     <a :href="item.link">
       <img :src="item.image" alt="" @load="imageLoad">   <!--监听轮播图是否加载完成 -->
     </a>
     </swiper-item>
   </swiper>
  </div>
</template>

<script>
import {Swiper, SwiperItem} from '@/components/common/swiper';
export default {
  name: "HomeSwiper",
  props:{  //
    banners:{
        type:Array,
          default(){
            return []
  }
}
  },
  data() {
    return {
      isLoad:false
    }
  },
  methods: {
    imageLoad(){
      if(!this. isLoad){  //只发送一次事件，只要第一个轮播图图片加载完，就不再发送事件
      this.$emit('swiperImageLoad')
      this.isLoad=true
      }
      
  }
  },
  components:{
    Swiper,
    SwiperItem
  },
};
</script>

<style scoped></style>